interface IDataConfig {
    [key: string]: string[]
}

// 在html中标签所在位置的信息
// todo 注意调整 template.html 中模板的位置，也要哎这里同步调整一下 ~~~
export const posInfo = [
    '<\/title>',
    '<%- mallCommonComponentCss %>',
    '<%- base %>',
    '<%- risk %>',
    '<%- security %>',
    '<%- eventemiter %>',
    '<%- dra %>',
    '<%- mallCommonComponentJs %>',
]

/**
 * 资源信息
 * */
const dataConfig: IDataConfig = {
    base: [
        '<script type="text/javascript" src="//misc.360buyimg.com/jdf/??/1.0.0/unit/base/5.0.0/base.js,/lib/jquery-1.6.4.js"></script>'
    ],

    risk: [
        '<script src="https://storage.360buyimg.com/jsresource/risk/handler.js"></script>'
    ],

    security: [
        '<script src="//storage.360buyimg.com/webcontainer/js_security_v3_0.1.6.js?v=2024-06-20-17"></script>',
        '<script src="//storage.360buyimg.com/retail-mall/lib/sha256-new.js?v=2024-06-20-17"></script>',
        '<script src="//gias.jd.com/js/pc-tk.js?v=2024-06-20-17"></script>'
    ],

    eventemiter: [
        '<script type="text/javascript" src="https://storage.360buyimg.com/retail-mall/lib/eventemiter.js?t=1"></script>'
    ],

    dra: [
        `<script>
      try {
        !function() {
          'use strict'
          !function(e, r, n, t) {
            var o = {
              pre_m: [], run: function(e) {
                for (var r = arguments.length, n = new Array(r > 1 ? r - 1 : 0), t = 1; t < r; t++) n[t - 1] = arguments[t]
                o.pre_m.push({ method: e, args: n })
              },
            }
            e[n] = o
            var a = function(e, r) {
              void 0 === o[e] && (o[e] = []), o[e].push(r)
            }
            'addEventListener' in e && 'removeEventListener' in e && (o.errorHandler = function(r) {
              var n = (r = r || e.event).target || r.srcElement
              n instanceof Element || n instanceof HTMLElement ? a('s_err', r) : a('err', r)
            }, o.rejectionHandler = function(e) {
              a('reject', e)
            }, e.addEventListener('error', o.errorHandler, !0), e.addEventListener('unhandledrejection', o.rejectionHandler, !0)), 'PerformanceLongTaskTiming' in e && (o.entries = [], o.observer = new PerformanceObserver((function(e) {
              o.entries = o.entries.concat(e.getEntries())
            })), o.observer.observe({ entryTypes: ['longtask'] }))
            var s = e.document.createElement('script')
            s.src = r, s.crossOrigin = 'anonymous', s.setAttribute('globalName'.toLowerCase(), n), s.setAttribute('preCollect'.toLowerCase(), t), e.document.getElementsByTagName('head')[0].appendChild(s)
          }(window, 'https://storage.360buyimg.com/dev-static/dra/probe-web/1.0.0/browser.js', 'dra', '__dra_PreCollectedData__')
        }()
      } catch (error) {
        console.error('烛龙监控自执行方法错误：', error)
      }
    </script>`,
        `<script>
      try {
        window.dra.run('init', { aid: '<%= aid %>' })
        window.dra.run('start')
      } catch (error) {
        console.error('烛龙监控初始化错误：', error)
      }
    </script>`
    ],

    mallCommonComponentCss: [
        '<link href="//storage.360buyimg.com/retail-mall/mall-common-component/pre/0.0.10/css/index.f41ad60c.css" rel="stylesheet" />'
    ],

    mallCommonComponentJs: [
        '<script defer src="//storage.360buyimg.com/retail-mall/mall-common-component/pre/0.0.10/js/index.f41ad60c.js"></script>'
    ]
}

export default dataConfig